package com.csun.nusing.ui.familyactivity;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.csun.nusing.R;
import com.csun.nusing.bean.UrlBean;
import com.csun.nusing.bean.jsonbean.BaseJsonBean;
import com.csun.nusing.bean.jsonbean.DataJsonBean;
import com.csun.nusing.bean.jsonbean.FamilyDeviceListJsonBean;
import com.csun.nusing.bean.jsonbean.SearchDeviceIdFromNo;
import com.csun.nusing.bean.jsonbean.SearchNoDeviceBindOlderJsonBean;
import com.csun.nusing.bean.jsonbean.SearchOlderByDeviceIdJsonBean;
import com.csun.nusing.bean.jsonbean.SleepDeviceIdJsonBean;
import com.csun.nusing.presenter.CommonPresenter;
import com.csun.nusing.ui.BaseActivity;
import com.csun.nusing.util.L;
import com.csun.nusing.util.SPUtils;
import com.csun.nusing.util.ToastUtil;
import com.google.gson.Gson;
import com.home.administrator.okhttplibrary.IOkTaskCallback;
import com.home.administrator.okhttplibrary.OkHttpTask;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 作者: Created by fzq on 2018/2/12 18:33
 * 邮箱: 15997123593@163.com
 */
public class FamilyDeviceInfoActivity extends BaseActivity<CommonPresenter> {

    private TextView addtv;
    private TextView codetv;
    private TextView typetv;
    private ImageView typeIv;
    private String type;
    private String code;
    private boolean isScan;
    private String authorization;
    private SearchDeviceIdFromNo devicejsonbean;
    private List<FamilyDeviceListJsonBean.AllDeviceDataBean> deviceList;
    private boolean ismyDeviceFlag;
    private String oldNmae;
    private int deviceId;
    private BaseJsonBean bean;
    private int deviceid;

    @Override
    public int getContentViewId() {
        return R.layout.activity_family_device_info;
    }

    @Override
    public void initSubViews(View view) {
        super.initSubViews(view);
        bindView();
    }


    private void bindView() {
        typeIv = (ImageView) findViewById(R.id.device_info_type_iv);
        typetv = (TextView) findViewById(R.id.device_info_type_tv);
        codetv = (TextView) findViewById(R.id.device_info_code_tv);
        addtv = (TextView) findViewById(R.id.family_device_info_add_tv);
        addtv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                add();
            }
        });
    }

    /**
     * 1.添加设备
     */
    private void add() {
        //扫码进入,未绑定自己
        if (isScan) {
            //已经添加过
            if (ismyDeviceFlag) {
                //绑定老人
                bindOlder();
            } else {
                //添加设备
                //查询设备是否被自己绑定
                Map<String, String> param = new HashMap<String, String>();
                param.put("deviceno", code);
                OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                        .addHeader("authorization", authorization)
                        .enqueue(new IOkTaskCallback() {
                            @Override
                            public void onSuccess(String result) {
                                if (result != null) {
                                    L.e("fzq", "绑定时获取错误码-------" + result);
                                    Gson gson = new Gson();
                                    BaseJsonBean bean = gson.fromJson(result, BaseJsonBean.class);
                                    if (bean.getMessage().equals("此设备已经被他人绑定")) {
                                        showother();
                                    }else {
                                        addDevice();
                                    }
                                }
                            }
                        }).start(UrlBean.SelectDeviceOneURL);

            }
        } else {
            //绑定老人
            bindOlder();
        }
    }


    /**
     * 添加设备
     */
    private void addDevice() {
        if (type.equals("0")) {
            addFollow();
        } else if (type.equals("1")) {
            addWatch();
        } else if (type.equals("2")) {
            addBed();
        } else if (type.equals("3")) {
            addAlert();
        }
    }

    /**
     * 绑定老人和设备
     */
    private void bindOlder() {
        //绑定时获取错误码

        //接口-->查询设备的绑定状态
//        1.设备未绑定老人  --属于自己
//        2.设备不属于自己
//        3.设备已被绑定老人  --属于自己

//        if (设备未绑定老人  --属于自己){
//            searchOlder();
//        }else if(设备不属于自己){
//            showother();
//        }else if(设备已被绑定老人  --属于自己){
//            reBind();
//        }

        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceno", code);
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("fzq", "绑定时获取错误码-------" + result);
                            Gson gson = new Gson();
                            BaseJsonBean bean = gson.fromJson(result, BaseJsonBean.class);
                            if (bean.getMessage().equals("查询成功")) {
                                searchDeviceId();
//                                searchOlder();
                            } else if (bean.getMessage().equals("您已经绑定过该床垫")) {
                                searchDeviceId();
//                                reBind();
                            } else if (bean.getMessage().equals("此设备已经被他人绑定")) {
                                showother();
                            }
                        }
                    }
                }).start(UrlBean.SelectDeviceOneURL);


    }

    /**
     * 搜索设备id
     */
    private void searchDeviceId() {
//        查询床垫有没有绑定老人
        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceno", code);
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("fzq", "查询床垫有没有绑定老人-------" + result);
                            Gson gson = new Gson();
                            DataJsonBean datajsonbean = gson.fromJson(result,DataJsonBean.class);
                            if (datajsonbean.getData().equals("床垫没有绑定老人")){
                                //
//                                搜索设备id
                                searchDeviceid();

                            }else{
                                //搜索设备id
                                //搜索老人名字
                                //解绑
                                searchSleepId();
                            }
                        }
                    }
                }).start(UrlBean.selectDeviceTwoURL);
}

    public void searchDeviceid(){
        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceno", code);
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("fzq", "根据sn码查询床垫id-------" + result);
                            Gson gson = new Gson();
                            SleepDeviceIdJsonBean sleepdeviceidbean = gson.fromJson(result,SleepDeviceIdJsonBean.class);
                            if ( sleepdeviceidbean!=null&& sleepdeviceidbean.getData()!=null&& sleepdeviceidbean.getData().size()!=0) {
                                deviceid = sleepdeviceidbean.getData().get(0).getId();
                                //根据id查询设备绑定状态
                                searchOlder();
                            }
                        }
                    }
                }).start(UrlBean.xSleepShowAllURL);
    }

    /**
     * 根据deviceCode设备id
     */
    private void searchSleepId() {
        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceno", code);
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("fzq", "根据sn码查询床垫id-------" + result);
                            Gson gson = new Gson();
                            SleepDeviceIdJsonBean sleepdeviceidbean = gson.fromJson(result,SleepDeviceIdJsonBean.class);
                            if ( sleepdeviceidbean!=null&& sleepdeviceidbean.getData()!=null&& sleepdeviceidbean.getData().size()!=0) {
                                deviceid = sleepdeviceidbean.getData().get(0).getId();
                                //根据id查询设备绑定状态
                                searchBindStatus(deviceid);
                            }
                        }
                    }
                }).start(UrlBean.xSleepShowAllURL);
    }
    /**
     * 根据设备id查询老人
     * @param deviceid
     */
    private void searchBindStatus(int deviceid) {
        Map<String, String> param = new HashMap<String, String>();
        param.put("id", ""+deviceid);
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("fzq", "根据设备id查询老人-------" + result);
                            Gson gson = new Gson();
                            SearchOlderByDeviceIdJsonBean sleepdeviceidbean = gson.fromJson(result,SearchOlderByDeviceIdJsonBean.class);
                            if ( sleepdeviceidbean!=null&& sleepdeviceidbean.getData()!=null) {
                                oldNmae = sleepdeviceidbean.getData().getName();
                                //根据id查询设备绑定状态
                                reBind();
                            }
                        }
                    }
                }).start(UrlBean.selectOldManByDeviceURL);

        //oldNmae
//        reBind();

    }

    /**
     * //设备属于自己
     * 搜索未绑定设备的老人列表
     */
    private void searchOlder() {
        Map<String, String> param = new HashMap<String, String>();
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("fzq", "搜索未绑定设备的老人列表-------" + result);
                            Gson gson = new Gson();
//                            controlOldList();
                            SearchNoDeviceBindOlderJsonBean bean = gson.fromJson(result, SearchNoDeviceBindOlderJsonBean.class);
                            if (bean != null) {
                                control(bean.getData());
                            }
                        }
                    }
                }).start(UrlBean.selectNoDeviceOldmanURL);

    }

    //      1.查询未绑定设备的老人列表
//        0 添加老人  绑定该老人
//        1.弹出绑定老人名字
//        多. 老人列表,点击绑定
    private void control(List<SearchNoDeviceBindOlderJsonBean.SearchNoDeviceBindOlderDataBean> data) {
        if (data != null) {
            if (data.size() == 0) {
                addOlderandBind();
            } else if (data.size() == 1) {
                showNormalDialog(data.get(0));
            } else {
                showSingleChoiceDialog(data);
            }
        } else {
            addOlderandBind();
        }
    }

    /**
     * 没有老人
     * 老人添加界面
     * 右上角是添加按钮并完成绑定功能
     * 然后返回到主界面
     */
    private void addOlderandBind() {
        Intent intent = new Intent(this, DeviceBindOlderActivity.class);
        intent.putExtra("deviceId", ""+deviceid);
        startActivity(intent);
    }


    /**
     * 单老人绑定
     *
     * @param searchNoDeviceBindDataBean
     */
    private void showNormalDialog(final SearchNoDeviceBindOlderJsonBean.SearchNoDeviceBindOlderDataBean searchNoDeviceBindDataBean) {
        /* @setIcon 设置对话框图标
         * @setTitle 设置对话框标题
         * @setMessage 设置对话框消息提示
         * setXXX方法返回Dialog对象，因此可以链式设置属性
         */
        final AlertDialog.Builder normalDialog =
                new AlertDialog.Builder(this);
        normalDialog.setTitle(R.string.bang_ding);
        normalDialog.setMessage(getString(R.string.enter_device_with) + searchNoDeviceBindDataBean.getName() + getString(R.string.older_bind));
        normalDialog.setPositiveButton(getString(R.string.enter),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //...To-do
                        bindOlderid(searchNoDeviceBindDataBean.getId());
                    }
                });
        normalDialog.setNegativeButton(getString(R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //...To-do
                        dialog.dismiss();
                    }
                });
        // 显示
        normalDialog.show();
    }


    /**
     * 多老人绑定
     */
    int yourChoice;

    private void showSingleChoiceDialog(final List<SearchNoDeviceBindOlderJsonBean.SearchNoDeviceBindOlderDataBean> data) {
        String[] items = new String[data.size()];
        for (int i = 0; i < data.size(); i++) {
            items[i] = data.get(i).getName();
        }
        yourChoice = -1;
        AlertDialog.Builder singleChoiceDialog =
                new AlertDialog.Builder(this);
        singleChoiceDialog.setTitle(getString(R.string.bang_ding));
        // 第二个参数是默认选项，此处设置为0
        singleChoiceDialog.setSingleChoiceItems(items, 0,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        yourChoice = which;
                    }
                });
        singleChoiceDialog.setPositiveButton(getString(R.string.enter),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (yourChoice != -1) {
                            bindOlderid(data.get(yourChoice).getId());
                        }
                    }
                });
        singleChoiceDialog.setNegativeButton(getString(R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
        singleChoiceDialog.show();
    }

    /**
     * 绑定老人与设备
     *
     * @param olderId
     */
    private void bindOlderid(int olderId) {
        Map<String, String> param = new HashMap<String, String>();
        param.put("oldmanid", "" + olderId);
        param.put("mattressid", ""+deviceid);
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("FZQ", "绑定老人与设备---" + result);
                            Gson gson = new Gson();
                            BaseJsonBean bean = gson.fromJson(result, BaseJsonBean.class);
                            if (bean.isStatus()) {
                                ToastUtil.showMessage(getApplicationContext(), R.string.bang_ding_successful);
                            }
                        }
                    }
                }).start(UrlBean.BEDBINDOLDERURL);
    }

    /**
     * 通知解绑
     */
    private void showother() {
        final AlertDialog.Builder normalDialog =
                new AlertDialog.Builder(this);
        normalDialog.setTitle(R.string.unbind);
        normalDialog.setMessage(getString(R.string.device_is_bind_tell_other));
        normalDialog.setPositiveButton(getString(R.string.enter),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //...To-do
                        dialog.dismiss();
                    }
                });
    }


    /**
     * 解除绑定
     */
    private void reBind() {
        //需要查询老人绑定的设备列表
        //有的化就解绑
        final AlertDialog.Builder normalDialog =
                new AlertDialog.Builder(this);
        normalDialog.setTitle(R.string.unbind);
        normalDialog.setMessage(getString(R.string.enter_device_with) + oldNmae + getString(R.string.older_unbind));
        normalDialog.setPositiveButton(getString(R.string.enter),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //...To-do
                        //解绑
                        //解绑接口
                        unBinder();
                    }
                });
        normalDialog.setNegativeButton(getString(R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        //...To-do
                        dialog.dismiss();
                    }
                });
        // 显示
        normalDialog.show();
    }

    /**
     * 解绑,根据code
     */
    private void unBinder() {
        //查询设备ID
        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceno", code);
        param.put("pageNo", "1");
        param.put("pageSize", "1");
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("fzq", "-------" + result);
                            Gson gson = new Gson();
                            devicejsonbean = gson.fromJson(result,
                                    SearchDeviceIdFromNo.class);
                            if (devicejsonbean != null) {
                                if (devicejsonbean.getData() != null) {
                                    controlfollowList(devicejsonbean.getData());
                                }
                            }
                        }
                    }
                }).start(UrlBean.DEVICESLEEPSHOWURL);
    }

    private void controlfollowList(SearchDeviceIdFromNo.SearchDeviceIdDataBean data) {
        if (data != null && data.getList() != null) {
            if (data.getList().size() != 0) {
                deviceId = data.getList().get(0).getId();
                //解绑设备
                Map<String, String> param = new HashMap<String, String>();
                param.put("id", "" + deviceId);
                OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                        .addHeader("authorization", authorization)
                        .enqueue(new IOkTaskCallback() {
                            @Override
                            public void onSuccess(String result) {
                                if (result != null) {
                                    Gson gson = new Gson();
                                    bean = gson.fromJson(result, BaseJsonBean.class);
                                    if (bean.isStatus()) {
                                        ToastUtil.showMessage(getApplicationContext(), R.string.unbind_successful);
                                    }
                                }
                            }
                        }).start(UrlBean.DeviceRelieveURL);
            }
        }
    }


    @Override
    public void initData() {
        super.initData();
        Intent intent = getIntent();
        Bundle bundle = intent.getExtras();
        String url = bundle.getString("url");
        isScan = bundle.getBoolean("SCAN", false);
        L.e("------", url);
        if (url != null) {
            String[] urlss = url.split(",");
            if (urlss != null && urlss.length > 1) {
                type = urlss[0];
                code = urlss[1];
                controltype();
                codetv.setText("" + code);
            }
        }
        searchAllDevice();
        //查询自己的设备列表
    }

    /**
     * 搜索设备列表
     */
    private void searchAllDevice() {
        authorization = (String) SPUtils.get(this, "authorization", "");
        Map<String, String> param = new HashMap<String, String>();
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            L.e("fzq", "-------" + result);
                            Gson gson = new Gson();
                            FamilyDeviceListJsonBean devicesjsonbean = gson.fromJson(result,
                                    FamilyDeviceListJsonBean.class);
                            if (devicesjsonbean != null) {
                                if (devicesjsonbean.getData() != null) {
                                    deviceList = devicesjsonbean.getData();
                                    controldeviceList();
                                }
                            }
                        }
                    }
                }).start(UrlBean.FAMILYDEVICESHOWURL);
    }

    private void controldeviceList() {
        ismyDeviceFlag = false;
        L.e("-------", "controldeviceList");
        for (int i = 0; i < deviceList.size(); i++) {
            if (code.equals(deviceList.get(i).getDeviceNo())) {
                ismyDeviceFlag = true;
                L.e("-------", "ismyDeviceFlag = true");
                break;
            }
        }
    }


    /**
     * 设备类型
     */
    private void controltype() {
        switch (type) {
            case "0":
                typeIv.setImageResource(R.drawable.shebei_icon_sfy_js);
                typetv.setText(R.string.device_follow);
                break;
            case "1":
                typeIv.setImageResource(R.drawable.shebei_icon_shoubiao_js);
                typetv.setText(R.string.device_watch);
                break;
            case "2":
                typeIv.setImageResource(R.drawable.shebei_icon_chuangdian_js);
                typetv.setText(R.string.device_sleep);
                break;
            case "3":
                typeIv.setImageResource(R.drawable.shebei_icon_baojing_js);
                typetv.setText(R.string.device_alarm);
                break;

        }
    }


    private void addAlert() {
        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceNo", code + "");
        param.put("deviceType", type + "");
        param.put("deviceInfo", "");
        param.put("deviceMac", "");
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            Gson gson = new Gson();
                            BaseJsonBean baseJsonBean = gson.fromJson(result,
                                    BaseJsonBean.class);
                            if (baseJsonBean.isStatus()) {
                                ToastUtil.showMessage(getApplicationContext(),
                                        baseJsonBean.getMessage());
//                                info();
                            } else {
                                ToastUtil.showMessage(getApplicationContext(),
                                        baseJsonBean.getMessage());
                            }
                        }
                    }
                }).start(UrlBean.ADDALERTURL);
    }

    private void addBed() {
        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceNo", code + "");
        param.put("deviceType", type + "");
        param.put("deviceInfo", "");
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            Gson gson = new Gson();
                            BaseJsonBean baseJsonBean = gson.fromJson(result,
                                    BaseJsonBean.class);
                            if (baseJsonBean.isStatus()) {
//                                ToastUtil.showMessage(getApplicationContext(),
//                                        baseJsonBean.getMessage());
                                info();
                            } else {
                                ToastUtil.showMessage(getApplicationContext(),
                                        baseJsonBean.getMessage());
                            }
                        }
                    }
                }).start(UrlBean.ADDSLEEPURL);
    }

    private void addWatch() {
        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceNo", code + "");
        param.put("deviceType", type + "");
        param.put("deviceInfo", "");
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            Gson gson = new Gson();
                            BaseJsonBean baseJsonBean = gson.fromJson(result,
                                    BaseJsonBean.class);
                            if (baseJsonBean.isStatus()) {
                                ToastUtil.showMessage(getApplicationContext(),
                                        baseJsonBean.getMessage());
//                                info();
                            } else {
                                ToastUtil.showMessage(getApplicationContext(),
                                        baseJsonBean.getMessage());
                            }
                        }
                    }
                }).start(UrlBean.ADDWATCHURL);
    }

    /**
     * 添加随访仪
     *
     * @param
     * @return void
     * @throws
     * @Description: TODO
     * @author fzq
     * @date 2017-11-17
     */
    private void addFollow() {
        Map<String, String> param = new HashMap<String, String>();
        param.put("deviceNo", code + "");
        param.put("deviceType", type + "");
        param.put("deviceInfo", "");
        param.put("androidMac", "");
        param.put("iosMac", "");
        OkHttpTask.newInstance(this).post(param, OkHttpTask.OkHttpTaskBuidler.OkType.form)
                .addHeader("authorization", authorization)
                .enqueue(new IOkTaskCallback() {
                    @Override
                    public void onSuccess(String result) {
                        if (result != null) {
                            Gson gson = new Gson();
                            BaseJsonBean baseJsonBean = gson.fromJson(result,
                                    BaseJsonBean.class);
                            if (baseJsonBean.isStatus()) {
                                ToastUtil.showMessage(getApplicationContext(),
                                        baseJsonBean.getMessage());
//                                info();
                            } else {
                                ToastUtil.showMessage(getApplicationContext(),
                                        baseJsonBean.getMessage());
                            }
                        }
                    }
                }).start(UrlBean.ADDFOLLOWURL);
    }

    /**
     * 跳转绑定界面
     */
    private void info() {
        ToastUtil.showMessage(this, getString(R.string.add_successful));
        //绑定老人
        bindOlder();
    }


}
